package org.lemon.transport.context.service.queue.stats;

public class MessagesStats {

    private final StatsCounter totalCounter;
    private final StatsCounter successfulCounter;
    private final StatsCounter failedCounter;

    public MessagesStats(StatsCounter totalCounter, StatsCounter successfulCounter, StatsCounter failedCounter) {
        this.totalCounter = totalCounter;
        this.successfulCounter = successfulCounter;
        this.failedCounter = failedCounter;
    }

    public void incrementTotal() {
        incrementTotal(1);
    }

    public void incrementTotal(int amount) {
        totalCounter.add(amount);
    }

    public void incrementSuccessful() {
        successfulCounter.add(1);
    }

    public void incrementSuccessful(int amount) {
        incrementSuccessful(amount);
    }

    public void incrementFailed() {
        failedCounter.add(1);
    }

    public void incrementFailed(int amount) {
        incrementFailed(amount);
    }

    public int getTotal(int amount) {
        return totalCounter.get();
    }

    public int getSuccessful(int amount) {
        return successfulCounter.get();
    }

    public int getFailed(int amount) {
        return failedCounter.get();
    }

    public void reset() {
        totalCounter.clear();
        successfulCounter.clear();
        failedCounter.clear();
    }
}
